package Control;
import Game.ActionType;
import org.jetbrains.annotations.NotNull;

public class Translator {
    public static ActionType translate(String cmd) throws Exception {
        char _cmd = cmd.charAt(0);
        return getActionType(_cmd);
    }

    @NotNull
    static ActionType getActionType(char _cmd) throws Exception {
        switch (_cmd) {
            case 'W', 'w' : return ActionType.UP;
            case 'A', 'a' : return ActionType.LEFT;
            case 'S', 's' : return ActionType.DOWN;
            case 'D', 'd' : return ActionType.RIGHT;
            case ' ' : return ActionType.ROTATE;
            default : throw new Exception("为定义的操作!");
        }
    }
}
